﻿using FBroSharp.Callback;
using FBroSharp.Const;
using FBroSharp.DataType;
using FBroSharp.Event;
using FBroSharp.Lib;
using FBroSharp.Value;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace wss测试
{



    //服务器回调
    class FBroSharpServerHandleDis : FBroSharpServerHandle
    {
        const string format = "方法:{0} 地址:{1}";
        public override void OnClientConnected(IFBroSharpServer server, int connection_id)
        {
            Console.WriteLine(String.Format(format, MethodBase.GetCurrentMethod().Name, server.GetAddress()));
        }

        public override void OnClientDisconnected(IFBroSharpServer server, int connection_id)
        {
            Console.WriteLine(String.Format(format, MethodBase.GetCurrentMethod().Name, server.GetAddress()));
        }

        public override void OnHttpRequest(IFBroSharpServer server, int connection_id, string client_address, IFBroSharpRequest request)
        {
            Console.WriteLine(String.Format(format, MethodBase.GetCurrentMethod().Name, server.GetAddress()));
        }

        public override void OnServerCreated(IFBroSharpServer server)
        {
            Console.WriteLine(String.Format(format, MethodBase.GetCurrentMethod().Name, server.GetAddress()));
        }

        public override void OnServerDestroyed(IFBroSharpServer server)
        {
            Console.WriteLine(String.Format(format, MethodBase.GetCurrentMethod().Name, server.GetAddress()));
        }

        public override void OnWebSocketConnected(IFBroSharpServer server, int connection_id)
        {
            Console.WriteLine(String.Format(format, MethodBase.GetCurrentMethod().Name, server.GetAddress()));
        }

        public override void OnWebSocketMessage(IFBroSharpServer server, int connection_id, byte[] data)
        {
            Console.WriteLine(String.Format(format, MethodBase.GetCurrentMethod().Name, server.GetAddress()));
            server.SendWebSocketMessage(connection_id, data);
        }

        public override void OnWebSocketRequest(IFBroSharpServer server, int connection_id, string client_address, IFBroSharpRequest request, IFBroSharpCallback callback)
        {
            Console.WriteLine(String.Format(format, MethodBase.GetCurrentMethod().Name, server.GetAddress()));
        }
    }


}
